package com.cby.android.base.aidl

import android.os.RemoteException
import kotlin.Throws
import com.cby.android.base.ILoginCallback
import com.cby.android.base.aidl.UserManager.SingleTon
import com.cby.android.base.aidl.bean.User

/**
 * @author ChenBaoyang
 * @description: UserManager
 * @date 2021/9/3 14:22
 */
class UserManager private constructor() {
    private var user: User? = null
    private var gameId: String? = null
    private var orientation = 0
    private var autoLogin = false

    companion object SingleTon {
        val instance = UserManager()
    }

    fun init(gameId: String?, orientation: Int, autoLogin: Boolean) {
        this.gameId = gameId
        this.orientation = orientation
        this.autoLogin = autoLogin
    }

    @Throws(RemoteException::class)
    fun doLogin(callback: ILoginCallback?) {
        if (callback != null) {
            user = User("jason", "2861", 1, "qweasdzxc")
            callback.onLoginFinish(user, 100, "登录成功")
        }
    }

    val userId: String?
        get() = if (user != null) {
            user!!.userId
        } else ""

}